package o;

import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.source.TrackGroupArray;

final class abj {
    public abl ʻ;
    public TrackGroupArray ʼ;
    public boolean ʽ;
    public final aiu[] ˊ;
    private final aim ˊॱ;
    public final Object ˋ;
    private final alb ˋॱ;
    public final aih ˎ;
    public final boolean[] ˏ;
    private long ˏॱ;
    private ala ͺ;
    public boolean ॱ;
    private final abm[] ॱˊ;
    public abj ॱॱ;
    public ala ᐝ;

    public abj(abm[] o_abmArr, long j, alb o_alb, alc o_alc, aim o_aim, abl o_abl) {
        aih o_ahx;
        this.ॱˊ = o_abmArr;
        this.ˏॱ = j - o_abl.ˊ;
        this.ˋॱ = o_alb;
        this.ˊॱ = o_aim;
        this.ˋ = amm.ॱ(o_abl.ˎ.ˋ);
        this.ʻ = o_abl;
        this.ˊ = new aiu[o_abmArr.length];
        this.ˏ = new boolean[o_abmArr.length];
        aih ˊ = o_aim.ˊ(o_abl.ˎ, o_alc, o_abl.ˊ);
        if (o_abl.ˎ.ˏ != Long.MIN_VALUE) {
            o_ahx = new ahx(ˊ, true, 0, o_abl.ˎ.ˏ);
        } else {
            o_ahx = ˊ;
        }
        this.ˎ = o_ahx;
    }

    public long ॱ(long j) {
        return ˋ() + j;
    }

    public long ˏ(long j) {
        return j - ˋ();
    }

    public long ˋ() {
        return this.ˏॱ;
    }

    public long ˏ() {
        return this.ʻ.ˊ + this.ˏॱ;
    }

    public boolean ॱ() {
        return this.ॱ && (!this.ʽ || this.ˎ.ॱ() == Long.MIN_VALUE);
    }

    public long ˎ() {
        if (!this.ॱ) {
            return this.ʻ.ˊ;
        }
        long ॱ;
        if (this.ʽ) {
            ॱ = this.ˎ.ॱ();
        } else {
            ॱ = Long.MIN_VALUE;
        }
        return ॱ == Long.MIN_VALUE ? this.ʻ.ˏ : ॱ;
    }

    public long ˊ() {
        return !this.ॱ ? 0 : this.ˎ.ˏ();
    }

    public void ˏ(float f) throws ExoPlaybackException {
        this.ॱ = true;
        this.ʼ = this.ˎ.ˋ();
        ˋ(f);
        long ˋ = ˋ(this.ʻ.ˊ, false);
        this.ˏॱ += this.ʻ.ˊ - ˋ;
        this.ʻ = this.ʻ.ˎ(ˋ);
    }

    public void ˊ(long j) {
        if (this.ॱ) {
            this.ˎ.ॱ(ˏ(j));
        }
    }

    public void ˎ(long j) {
        this.ˎ.ˋ(ˏ(j));
    }

    public boolean ˋ(float f) throws ExoPlaybackException {
        int i = 0;
        ala ˋ = this.ˋॱ.ˋ(this.ॱˊ, this.ʼ);
        if (ˋ.ˎ(this.ͺ)) {
            return false;
        }
        this.ᐝ = ˋ;
        akz[] ˊ = this.ᐝ.ˏ.ˊ();
        int length = ˊ.length;
        while (i < length) {
            akz o_akz = ˊ[i];
            if (o_akz != null) {
                o_akz.ˋ(f);
            }
            i++;
        }
        return true;
    }

    public long ˋ(long j, boolean z) {
        return ˋ(j, z, new boolean[this.ॱˊ.length]);
    }

    public long ˋ(long j, boolean z, boolean[] zArr) {
        int i = 0;
        while (i < this.ᐝ.ˎ) {
            boolean z2;
            boolean[] zArr2 = this.ˏ;
            if (z || !this.ᐝ.ˎ(this.ͺ, i)) {
                z2 = false;
            } else {
                z2 = true;
            }
            zArr2[i] = z2;
            i++;
        }
        ॱ(this.ˊ);
        ˏ(this.ᐝ);
        akx o_akx = this.ᐝ.ˏ;
        long ॱ = this.ˎ.ॱ(o_akx.ˊ(), this.ˏ, this.ˊ, zArr, j);
        ˎ(this.ˊ);
        this.ʽ = false;
        for (i = 0; i < this.ˊ.length; i++) {
            if (this.ˊ[i] != null) {
                amm.ˏ(this.ᐝ.ˏ(i));
                if (this.ॱˊ[i].f_() != 6) {
                    this.ʽ = true;
                }
            } else {
                amm.ˏ(o_akx.ˊ(i) == null);
            }
        }
        return ॱ;
    }

    public void ʼ() {
        ˏ(null);
        try {
            if (this.ʻ.ˎ.ˏ != Long.MIN_VALUE) {
                this.ˊॱ.ॱ(((ahx) this.ˎ).ˊ);
            } else {
                this.ˊॱ.ॱ(this.ˎ);
            }
        } catch (Throwable e) {
            amz.ˊ("MediaPeriodHolder", "Period release failed.", e);
        }
    }

    private void ˏ(ala o_ala) {
        if (this.ͺ != null) {
            ˋ(this.ͺ);
        }
        this.ͺ = o_ala;
        if (this.ͺ != null) {
            ॱ(this.ͺ);
        }
    }

    private void ॱ(ala o_ala) {
        for (int i = 0; i < o_ala.ˎ; i++) {
            boolean ˏ = o_ala.ˏ(i);
            akz ˊ = o_ala.ˏ.ˊ(i);
            if (ˏ && ˊ != null) {
                ˊ.ˋ();
            }
        }
    }

    private void ˋ(ala o_ala) {
        for (int i = 0; i < o_ala.ˎ; i++) {
            boolean ˏ = o_ala.ˏ(i);
            akz ˊ = o_ala.ˏ.ˊ(i);
            if (ˏ && ˊ != null) {
                ˊ.ˏ();
            }
        }
    }

    private void ॱ(aiu[] o_aiuArr) {
        for (int i = 0; i < this.ॱˊ.length; i++) {
            if (this.ॱˊ[i].f_() == 6) {
                o_aiuArr[i] = null;
            }
        }
    }

    private void ˎ(aiu[] o_aiuArr) {
        int i = 0;
        while (i < this.ॱˊ.length) {
            if (this.ॱˊ[i].f_() == 6 && this.ᐝ.ˏ(i)) {
                o_aiuArr[i] = new aic();
            }
            i++;
        }
    }
}
